﻿<UserControl x:Class="Wen.UI.Main.ProcessListView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <UserControl.Resources>
    <DataTemplate x:Key="ProcessTemplate">
      <Grid Background="Transparent" x:Name="Root">
        <Button Command="{Binding DataContext.SelectProcessCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" CommandParameter="{Binding}" Style="{StaticResource SelectButtonStyle}">
          <Border x:Name="Bd" Margin="5" Padding="3">
            <StackPanel Orientation="Horizontal">
              <Image Width="32" Height="32" SnapsToDevicePixels="True" Source="{Binding Icon}" VerticalAlignment="Center" />
              <StackPanel Margin="6 0 0 0">
                <TextBlock Foreground="Black" Text="{Binding OwningProcess.MainWindowTitle}" />
                <TextBlock Foreground="Black" Text="{Binding OwningProcess.ProcessName}" />
              </StackPanel>
            </StackPanel>
          </Border>
        </Button>
      </Grid>
      <DataTemplate.Triggers>
        <DataTrigger Binding="{Binding IsSelected, RelativeSource={RelativeSource FindAncestor, AncestorType=ListBoxItem}}" Value="True">
          <Setter TargetName="Bd" Property="Background" Value="Orange" />
        </DataTrigger>
      </DataTemplate.Triggers>
    </DataTemplate>
  </UserControl.Resources>
	
	
  <Border Margin="3" CornerRadius="3" ClipToBounds="True">
    <Border.Background>
      <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#DFD7E5FF" Offset="0"/>
        <GradientStop Color="#F2CBD0DA" Offset="1"/>
      </LinearGradientBrush>
    </Border.Background>
    <Grid>
      <Grid.RowDefinitions>
        <RowDefinition Height="*" />
        <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>
      <ItemsControl ItemsSource="{Binding Processes}" ItemTemplate="{StaticResource ProcessTemplate}" Style="{StaticResource ProcessItemsControlStyle}" />
      <Button Grid.Row="1" Command="{Binding UpdateCommand}" Style="{StaticResource RefreshButtonStyle}" HorizontalAlignment="Left" ToolTip="Refresh list" />
    </Grid>
  </Border>
</UserControl>
